package practice1;

public class StudentA {
    // 定义成员变量
    private String name;
    private int age;
    private float chinese;
    private float math;
    private float english;

    // 设置各个类成员变量的方法
    public void setStudent(String name, int age, float chinese, float math, float english) {
        this.name = name;
        this.age = age;
        this.chinese = chinese;
        this.math = math;
        this.english = english;
    }

    // 计算总成绩的方法
    public float total() {
        return chinese + math + english;
    }

    // 计算平均成绩的方法
    public float average() {
        return total() / 3;
    }

    // 获取学生信息的方法
    @Override
    public String toString() {
        return "Name: " + name + ", Age: " + age + ", Chinese: " + chinese +
                ", Math: " + math + ", English: " + english +
                ", Total: " + total() + ", Average: " + average();
    }
}
